//SafeRoom.java
package proxy.wisereference;

/**
 *@author:youtubezou
 *@version:2012-7-25
 */
public class SafeRoom implements Room{
	private int subjectAmount = 3;
	private Person person;
	
	@Override
	public boolean enterRoom(Person person) {
		this.person = person;
		return true;
	}

	@Override
	public Subject getSubject() {
		int result = (int)(Math.random() * subjectAmount) + 1;
		Subject subject = null;
		switch(result){
		case 1:
			subject =  new Computer();
			break;
		case 2:
			subject = new Desk();
			break;
		case 3:
			subject = new Card();
			break;
		default:
			break;	
		}
				
		return subject;
	}

	@Override
	public void exitRoom() {
		person = null;
	}
	
	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

}
